<?php
	$protectid="305"; 
	include("../protect.php");
	
	include_once("../../config.inc.php");
	
	include_once(CFG_LIB_DIR.'mysqldb.inc.php');
	$objDb = new mysqldb();
	
	include_once(CFG_LIB_DIR."block.php");
	$Block = new clsBlock();
	
	include_once(CFG_LIB_DIR."generic.lib.php");
	$objBase = new clsBase();
	
	include(CFG_LIB_DIR."buy_car_cs.php");
	$objBuyCar = new Buy_CS();
	
	include_once(CFG_LIB_DIR."manage_page2.php");	
	$objManPage = new clsManagePage();
	$ProductID = $_GET['id'];
	
	$arrOrderState=array(
						"0"=>	"未付款",
						"1"=>	"等待买家付款",
						"2"=>	"已付款",
						"3"=>	"处理中",
						"4"=>	"卖家已经发货等待买家确认",
						"5"=>	"交易成功结束",
						"6"=> 	"退票"
						 );
	$arrOrderType=array(
						"0"=>	"<font color=\"#0000FF\">普通订票</font>",
						"1"=>	"<strong><font color=\"#0000FF\">普通购票</font></strong>",
						"2"=>	"<font color=\"red\">会员订票</font>",
						"3"=>	"<strong><font color=\"red\">会员购票</font></strong>",
						 );
	//分页获取数据
	//$OrderResult = $objManPage->GetResult('t1.*,t2.MemberName', '`'.con_strPREFIX.'buyorder` t1 inner join `hy_b_member` t2 on t1.UID=t2.MemberID ', ' ORDER BY t1.ID DESC', 20, true);
$OrderResult = $objManPage->GetResult('*', '`hy_b_order222` ', ' ORDER BY  ID DESC', 20, true);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrator's Control Panel</title>
<script type="text/javascript">
<!--
function showcontent(imgdom,s){
	var dom=document.getElementById("contenttr"+s);
	if(dom.style.display=="none"){
		dom.style.display="";
		imgdom.src="logo.jpg";
	}
	else{
		dom.style.display="none";
		imgdom.src="logo2.jpg";
	}
}
function setselall(s){
	var dom=document.getElementsByName("sel[]");
	var domflag=false;
	if(s==true){domflag=true;}
	for(i=0;i<dom.length;i++){
		dom[i].checked=domflag;
	}
}

function checkchoose(){
	var dom=document.getElementsByName("sel[]");
	var num=0;
	for(i=0;i<dom.length;i++){
		if(dom[i].checked==true){
			num +=1;
			break;
		}
	}
	if(num==0){
		alert('请选择要进行操作的记录');
		return false;
	}
	else{
		return true;
	}
}
-->
</script>
<?php include_once("../common/files.php"); ?>
</head>
<body id="main" >
<form name="form1" method="post" action="order_del.php" onsubmit="return checkchoose();">
<input name="action" id="action" type="hidden" value="del" />
<table summary="" id="pagehead" cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td><h1>查看订单</h1></td>
  </tr>
</table> 
	<table cellspacing="0" cellpadding="0" width="100%"  class="listtable">
    <tr bgcolor="#F3F7FF">
      <th width="8%"><input name="selAll" type="checkbox" value="" onclick="setselall(this.checked)" />
      全选</th>
      <th width="7%">查看明细</th>
      <th >订单号</th>
     
      <th width="20%">订购者</th>
      <th width="10%">状态</th>
      <th width="9%" ><strong>下订形式</strong></th>
      <th width="20%" >订购时间</th>
      <!--<th width="10%">操作</th>-->
    </tr>
<?php
	//输出 Manage Grid
	if(is_array($OrderResult))
	{
		foreach($OrderResult as $key => $Order)
		{
?>
    <tr>
   	  <td align="center" valign="middle"><input name="sel[]" id="sel[]" type="checkbox" value="<?=$Order['id']?>" /></td>
    	<td align="center"><img src="logo2.jpg"  style="cursor:hand;" onclick="javascript:showcontent(this,'<?=$Order['id']?>')" /></td>
    	<td align="center"><?php echo $Order['orderNum'];?></td>
    	
    	<td align="center"><?php echo $Order['memberName'];?></td>
      <td align="center"><?php echo $arrOrderState[$Order["state"]];?></td>
      <td align="center"><?php echo $arrOrderType[$Order["OrderType"]];?></td>
      <td align="center"><?php echo date("Y年m月d日 H时i分s秒",$Order['createdate']);?></td>
      <!--<td align="center"><a href="order_del.php?id=<? echo $Order['id'];?>&action=del" onClick="return confirm('你确定要删除吗？')" >删除</a></td>-->
    </tr>
    <tr id="contenttr<?=$Order['id']?>" style="display:none;">
      <td align="center" bgcolor="#F3F3F3">明细</td>
      <td colspan="8" align="left">
      <div >
        <div id="order_div">
            <?php
			
			//$price=$price.;
			
			echo "<table cellspacing='0' cellpadding='0' border=1 bordercolor=\"#F3ECCD\" width='100%'  >";
            
			echo "<tr align='left'>";
            echo "<td width='10%' align=\"left\">产品明细：</td><td align=\"left\">";
				//获取订单产品明细
			$productNames=explode(",",$Order['productName']);
			$prices=explode(",",$Order['price']);
			$buyNums=explode(",",$Order['buyNum']);
			$Floors=explode(",",$Order['Floor']);
			$Dates=explode(",",$Order['Date']);
			$Times=explode(",",$Order['Time']);
			$ZheKous=explode(",",$Order['ZheKou']);
			//$TotalPrices=explode(",",$Order['TotalPrice']);
			//var_dump($productNames);
			$geshu=sizeof($buyNums);
				if($geshu)
			{
				echo "<table cellspacing='0' cellpadding='0' border=1 bordercolor=\"#F3ECCD\" width='100%'  >
						  <tr  bgcolor=\"#F3F3F3\">
							<td width='30%'>产品名称</td>
							<td width='10%'>订购楼层</td>
							<td width='30%'>订购时间</td>
							<td width='10%'>价格(￥)</td>
							<td width='10%'>折扣</td>
							<td width='10%'>数量</td>
							
						  </tr>";
				for($i=0;$i<$geshu;$i++){
					
					echo "
						  <tr>
							<td>".$productNames[$i]."</td>
							<td>".$Floors[$i]."</td>
							<td>".$Dates[$i]."&nbsp;&nbsp;".$Times[$i]."</td>
							<td>".$prices[$i]."</td>
							<td>".$ZheKous[0]."</td>
							<td>".$buyNums[$i]."</td>
						
						  </tr>
					";
				}
				echo "<tr><td>合计:</td><td colspan=\"5\">".$Order['TotalPrice']."元</td></tr>";
				echo "</table>";
			}
			echo "</td>";
			echo "</tr>";

			echo "
			<tr>";
			
			$totalprice=$t_price*$t_buynum*$t_zhekou*0.1;
			
			
			echo "<tr>";
			echo "<td>固定电话：</td><td>".$Order['TEL']."</td>";
			echo "</tr>
			
			<tr>";
			echo "<td>联系手机：</td><td>".$Order['Phone']."</td>";
			echo "</tr>";
	
				
 
$SQL="SELECT * FROM `hy_b_paytype` where `ID`='".$Order['PayType']."'";
$objDb->query($SQL);
$rssA=$objDb->get_data();
$SQLB="SELECT * FROM `hy_b_sendtype` where `ID`='".$Order['SendType']."'";

$objDb->query($SQLB);
$rssB=$objDb->get_data();
	
	
			echo "<tr>";
			echo "<td align=\"left\">配送方式：</td><td align=\"left\">".$rssB[0]['TypeName']."&nbsp;&nbsp;".$rssB[0]['Money']."</td>";
			echo "</tr>
			<tr>";
			echo "<td>支付方式：</td><td>".$rssA[0]['TypeName']."</td>";
			echo "</tr>";
		
			echo "<tr>";
			echo "<td>Email：</td><td>".$Order['Email']."</td>";
			echo "</tr>
			<tr>";
			echo "<td>联系地址：</td><td>".$Order['Address']."</td>";
			echo "</tr>
			<tr>";
			if($Order['IsGetFaPiao']==1){
			echo "<tr>";
			echo "<td>发票类型：</td><td>".$Order['Email']."</td>";
			echo "</tr>
			<tr>";
			echo "<td>发票抬头：</td><td>".$Order['Address']."</td>";
			echo "</tr>
			<tr>
		    <tr>";
			echo "<td>发票内容：</td><td>".$Order['Address']."</td>";
			echo "</tr>
			<tr>";
			 }
			echo "<td>附言：</td><td>".$Order['Message']."</td>";
			echo "</tr>
			</table>";
            ?>
        </div>
      </div>      </td>
    </tr>
<?php	
		}
	}
?>
	</table>
	<br />
    <div style="text-align:left;">
    <input name="submit" type="submit" value="删除" />
    &nbsp;<input name="submit2" type="submit" value="未付款" onclick="document.getElementById('action').value='0';" />
    &nbsp;<input name="submit2" type="submit" value="等待买家付款" onclick="document.getElementById('action').value='1';" />
    &nbsp;<input name="submit2" type="submit" value="确认收款" onclick="document.getElementById('action').value='2';" />
    &nbsp;<input name="submit2" type="submit" value="处理中" onclick="document.getElementById('action').value='3';" />
    &nbsp;<input name="submit2" type="submit" value="已发货" onclick="document.getElementById('action').value='4';" />
    &nbsp;<input name="submit2" type="submit" value="确认收货" onclick="document.getElementById('action').value='5';" />
	&nbsp;<input name="submit2" type="submit" value="退票" onclick="document.getElementById('action').value='6';" />
    </div>
<?php	
	//输出分页
	echo $objManPage->ShowLink();
?>
</form>
<?php include "../bottom.php"; ?>
</body>
</html>
